package com.myapp.api.service.impl;

import com.myapp.api.entity.Course;
import com.myapp.api.mapper.CourseMapper;
import com.myapp.api.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseMapper mapper;

    @Override
    public List<Course> getCourses() {
        return mapper.getCourses();
    }

    @Override
    public Course getCourseById(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public Course getCourseByCid(String cid) {
        return mapper.getCourseByCid(cid);
    }

    @Override
    public Integer getCourseByOneCid(String cid) {
        return mapper.getCourseByOneCid(cid);
    }

    @Override
    public List<Course> getCoursebyCname(String cname) {
        return mapper.getCourseByCname(cname);
    }

    @Override
    public int addCourse(Course record) {
        return mapper.insertSelective(record);
    }

    @Override
    public int deleteCourseById(Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int putCourse(Course record) {
        return mapper.updateByPrimaryKeySelective(record);
    }
}
